/**
 * 
 */
package com.roc.util.constant;

import java.util.HashMap;

import org.apache.commons.lang3.StringUtils;

/**
 * @author chenkai 
 */
public enum TerminalFlag {
	 
	FLAG_CACELL("已解绑", "02"),
	 FLAG_ONE("正常", "01"),
	 FLAG_TWO("未开通", "2"),
	 FLAG_THREES("非正常","03"),
	 FLAG_THREE("已冻结", "00"),
	 FLAG_ILLEGALITY("非法占用", "04"),//违规
	 FLAG_FOUR("非正常","3"),//商户信息变更申请使用的状态
	 FLAG_FIVE("注销","4"),
	 FLAG_INVALID("作废","5");
	 
	 
	 
	private String code;
	private String name;
	private boolean editAble;
	private boolean enabled;

	private TerminalFlag( String name,String code) {
		this.code = code;
		this.name = name;
		
	}

	public boolean isEditAble() {
		return editAble;
	}

	public boolean isEnabled() {
		return enabled;
	}

	public String getCode() {
		return code;
	}

	public String getName() {
		return name;
	}

	public static TerminalFlag valueOfCode(String code) {
		if (StringUtils.isBlank(code)) {
			throw new IllegalArgumentException("SysLogType code " + code
					+ " is blank");
		}
		for (TerminalFlag ms : values()) {
			if (ms.getCode().equals(code)) {
				return ms;
			}
		}
		throw new IllegalArgumentException("SysLogType code " + code
				+ " is not exist");
	}
	
	/**
	 * 通过ID获取中文名称
	 * @param code
	 * @return
	 */
	public static String getName(String code) {
		if (StringUtils.isBlank(code)) {
			throw new IllegalArgumentException("MerberFlag code " + code
					+ " is blank");
		}
		for (TerminalFlag tf : values()) {
			if (tf.getCode().equals(code)) {
				return tf.getName();
			}
		}
		throw new IllegalArgumentException("MerberFlag code  " + code
				+ " is not exist");
	}
	
	/**
	 * 获取所有的枚举,以MAP返回
	 * @return
	 */
	public static HashMap<String,String> getAllEnumMap() {
		
		HashMap<String,String> map = new HashMap<String,String>();
		
		for (TerminalFlag tf : values()) {
			map.put(tf.getCode(), tf.getName());
		}
		
		return map;
		
	}
}
